Docker images: fix sudo swallowing env variables

Adds the -E argument to sudo calls which passes the environment to the called command. Ensures env variables which are
not defined with default in .env.example are available in Huginn.
Fixes encoding issue when loading agent gems which contain non ASCII characters.

Dominik Sander 8 lat temu
rodzic
commit
dce47b6b3b
3 zmienionych plików z 11 dodań i 6 usunięć
  1. 3 1
      docker/multi-process/scripts/init
  2. 1 0
      docker/scripts/setup
  3. 7 5
      docker/single-process/scripts/init

+ 3 - 1
docker/multi-process/scripts/init

@@ -1,6 +1,8 @@
1 1
 #!/bin/bash
2 2
 set -e
3 3
 
4
+export LC_ALL=en_US.UTF-8
5
+
4 6
 cd /app
5 7
 
6 8
 # Cleanup any leftover pid file
@@ -46,7 +48,7 @@ echo "RAILS_SERVE_STATIC_FILES=true" >> .env
46 48
 
47 49
 chmod ugo+r /app/.env
48 50
 source /app/.env
49
-sudo -u huginn -H bundle install --without test development --path vendor/bundle
51
+sudo -u huginn -H -E bundle install --without test development --path vendor/bundle
50 52
 
51 53
 # use default port number if it is still not set
52 54
 case "${DATABASE_ADAPTER}" in

+ 1 - 0
docker/scripts/setup

@@ -20,6 +20,7 @@ RAILS_ENV=production APP_SECRET_TOKEN=secret DATABASE_ADAPTER=sqlite3 ON_HEROKU=
20 20
 # Bundle again to get rid of the sqlite3 gem
21 21
 cp Gemfile.bak Gemfile
22 22
 RAILS_ENV=production APP_SECRET_TOKEN=secret DATABASE_ADAPTER=sqlite3 ON_HEROKU=true bundle install --without test development --path vendor/bundle -j 4
23
+chown huginn:huginn Gemfile.lock
23 24
 
24 25
 # Configure the unicorn server
25 26
 mv config/unicorn.rb.example config/unicorn.rb

+ 7 - 5
docker/single-process/scripts/init

@@ -1,6 +1,8 @@
1 1
 #!/bin/bash
2 2
 set -e
3 3
 
4
+export LC_ALL=en_US.UTF-8
5
+
4 6
 cd /app
5 7
 
6 8
 # Configure database based on linked container
@@ -40,18 +42,18 @@ case "${DATABASE_ADAPTER}" in
40 42
   *) echo "Unsupported database adapter. Available adapters are mysql2, and postgresql." && exit 1 ;;
41 43
 esac
42 44
 
43
-sudo -u huginn -H bundle install --without test development --path vendor/bundle
45
+sudo -u huginn -H -E bundle install --without test development --path vendor/bundle
44 46
 
45 47
 if [ -z $1 ]; then
46
-  sudo -u huginn -H bundle exec rake db:create db:migrate RAILS_ENV=${RAILS_ENV}
48
+  sudo -u huginn -H -E bundle exec rake db:create db:migrate RAILS_ENV=${RAILS_ENV}
47 49
 fi
48 50
 
49 51
 if [[ -z "${DO_NOT_SEED}" && -z $1 ]]; then
50
-  sudo -u huginn -H bundle exec rake db:seed RAILS_ENV=${RAILS_ENV}
52
+  sudo -u huginn -H -E bundle exec rake db:seed RAILS_ENV=${RAILS_ENV}
51 53
 fi
52 54
 
53 55
 if [ -z $1 ]; then
54
-  exec sudo -u huginn -H bundle exec unicorn -c config/unicorn.rb
56
+  exec sudo -u huginn -H -E bundle exec unicorn -c config/unicorn.rb
55 57
 else
56
-  exec sudo -u huginn -H bundle exec rails runner "$@" RAILS_ENV=${RAILS_ENV}
58
+  exec sudo -u huginn -H -E bundle exec rails runner "$@" RAILS_ENV=${RAILS_ENV}
57 59
 fi